﻿



CREATE PROCEDURE [dbo].[proc_Department_GetList_Bmbh]
	
	@Companyid INT,
	@departmentid INT 
	
AS
IF(@departmentid=0)
BEGIN
	SELECT Id,bmbh, case when len(bmbh)>4 then replicate('┆┄┄',(len(bmbh)-4)/2)+isnull(dname,'') else '◆'+isnull(dname,'') end as DName from Department where companyid=@Companyid and bmbh is not null order by bmbh	
END
ELSE
	BEGIN
		Declare @bmbh_T  varchar(30)		
		Select @bmbh_T=bmbh From department Where id=@departmentid
		SELECT id,bmbh, case when len(bmbh)>4 then replicate('┆┄┄',(len(bmbh)-4)/2)+isnull(dname,'') else '◆'+isnull(dname,'') end as DName from Department where companyid=@Companyid And Left(bmbh,Len(@bmbh_T))=@bmbh_T and bmbh is not null order by bmbh		
	END

